/*
Authors: Eli Yucht 300388949 and Lior Fass 300069705
Project: SCP (Switch Schedule Policy)
Description: Schedule class
*/


#ifndef SCHEDULE_H
#define SCHEDULE_H

#include <iostream>
using namespace std;

#include "list_of_flows.h"

#define ARGS_NUM 4
#define MAX_LINE_BUF 256

// Schedule class declaration
class Schedule
{
public:
	Schedule();
	int Check_Arguments(int argc, char *argv[]);
	int Initialize_Schedule(char* infile_name, char* outfile_name);
	int Do_Schedule_RR();
	~Schedule();
private:
	FILE* infile_p;
	FILE* outfile_p;
	long int current_time;
	Flow* head_flow_queue;
	Flow* tail_flow_queue;
	Flow* current_flow;
	
	int Load_data_to_Schedule();
	Flow* Find_Flow();
	int Get_Pkt_From_File(bool first_time);
	unsigned short int sport, dport;
	long int time_of_arrived, pkt_id;
	char* sadd, *dadd;
	unsigned short int length, weight;
	bool need_to_load_next_time;
	bool empty_queues;
	bool end_of_input;
	char line_buf[MAX_LINE_BUF];
	int Load_Flow();
	unsigned short int num_of_flows;
	unsigned short int counter_of_empty_flows;
	void Go_to_Next_Flow();

};

#endif // SCHEDULE_H